package com.kkwrite.regimen.provider.service.income;

import com.kkwrite.regimen.common.entity.dto.income.IncomeCountOutDTO;
import com.kkwrite.regimen.common.entity.dto.income.PageableIncomeDTO;
import com.kkwrite.regimen.provider.exception.DBNullException;
import com.kkwrite.regimen.provider.exception.ExtractCashException;
import com.kkwrite.regimen.provider.exception.ServiceException;

/**
 * @author jinying
 */
public interface IncomeService {

    /**
     * 分页查询收益
     *
     * @param page     页码
     * @param size     每页大小
     * @param userId   用户ID
     * @param sortType 排序类型
     * @return PageableIncomeDTO
     * @throws NumberFormatException 异常
     * @throws ServiceException      异常
     */
    PageableIncomeDTO queryIncome(Integer page, Integer size, Long userId, Integer sortType) throws NumberFormatException, ServiceException;

    /**
     * 统计用户收益
     *
     * @param userId 用户ID
     * @return IncomeCountOutDTO
     */
    IncomeCountOutDTO count(Long userId);

    /**
     * 用户提现
     *
     * @param amount 提现金额
     * @param userId 提现用户
     * @throws ExtractCashException 异常
     * @throws DBNullException      异常
     */
    void extractCash(Double amount, Long userId) throws ExtractCashException, DBNullException;

    /**
     * 保存收益记录
     *
     * @param userId      订单所属用户ID
     * @param orderCode   订单编号
     * @param orderAmount 订单金额
     * @param shopId      订单所属店铺ID
     */
    void incomeRecordMessageHandler(int userId, String orderCode, double orderAmount, int shopId);
}
